package servlet;

import eneity.News;
import service.UserManage;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class editNewsServlet extends HttpServlet {
    UserManage um=new UserManage();
    News n=new News();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        n.setNtitle(req.getParameter("title"));
        n.setNauthor(req.getParameter("author"));
        n.setNtid(req.getParameter("selectID"));
        n.setNid(req.getParameter("nid"));
        n.setNssmmary(req.getParameter("summany"));
        n.setNcontent(req.getParameter("mainText"));
        int result = um.editNews(n);
        if (result>0){
            req.getRequestDispatcher("topicInfoServlet").forward(req,resp);
        }
    }
}
